*Dissag milex data feature 
*Data file: 
*Do file: 


********************************
* Standard Stata Configuration *
********************************

clear all
set mem 999m
capture log close
set logtype text
cap cd "G:\My Drive\1_Research\disagg_milex_datafeature"
cap cd "C:\Users\jordan.becker\My Drive\1_Research\disagg_milex_datafeature"
log using "log\disagg_milex.log", replace
set more off


********************
* Prepare the Data *
********************
*Run Python Scraping File*
*May need to edit path in python scraping file below*
do "do/eda_nato_data_cleaning"
use "dta/nato_eda_compiled_data", clear
rename milburden Milburden
gen countryname=country
replace countryname = "Macedonia" if countryname == "North Macedonia"
replace countryname = "Bulgaria" if countryname =="Bulgaria "
replace countryname = "Slovakia" if countryname =="Slovak Republic"
drop if countryname == "Türkiye" & year<2022
replace countryname = "Turkey" if countryname =="Türkiye"
run do/name_to_cow_easy
list year countryname if ccode==.
drop if ccode==.
duplicates list ccode year
saveold "dta/nato_eda_compiled_data", replace


*start with basic disagg milex data*
use "dta\disagg_milex", clear

*generate nato_year_dummy*
#delimit;

replace nato_year_dummy=1 if year>=1949 & countryname=="Belgium"|countryname=="Canada" &year>=1949|countryname=="Denmark"&year>=1949|countryname=="France"&year>=1949|
countryname=="Iceland"&year>=1949|countryname=="Italy" & year>=1949|countryname=="Luxembourg"&year>=1949|countryname=="Netherlands"&year>=1949|countryname=="Norway"&year>=1949
|countryname=="Portugal"& year>=1949|countryname=="United Kingdom"&year>=1949|countryname=="United States"&year>=1949;
replace nato_year_dummy=1 if year>=1952 & countryname =="Greece"| year>=1952& countryname=="Turkey";
replace nato_year_dummy=1 if year>=1955&countryname=="Germany";
replace nato_year_dummy=1 if year>=1982& countryname=="Spain";
replace nato_year_dummy=1 if year>=1999 & countryname=="Czech Republic"| year>=1999&countryname=="Hungary"| year>=1999&countryname=="Poland";
replace nato_year_dummy=1 if year>=2004 & countryname=="Bulgaria"|year>=2004 &countryname=="Estonia"|year>=2004 &countryname=="Latvia"|year>=2004 &countryname=="Lithuania"|
year>=2004 &countryname=="Romania"|year>=2004 &countryname=="Slovakia"|year>=2004 &countryname=="Slovenia";
replace nato_year_dummy=1 if year>=2009 & countryname=="Albania"|year>=2009 &countryname=="Croatia"|year>=2016&countryname=="Montenegro";
replace nato_year_dummy=1 if year>=2020 & countryname=="Macedonia";
saveold "dta/disagg_milex_working", replace;

*generate eu_year_dummy*
#delimit;
gen eu_year_dummy=0;
replace eu_year_dummy=1 if year>=1958&countryname=="Belgium"|year>=1958&countryname=="France"|year>=1958&countryname=="Germany"|
year>=1958&countryname=="Italy"|year>=1958&countryname=="Luxembourg"|year>=1958&countryname=="Netherlands";
replace eu_year_dummy=1 if countryname=="Denmark"&year>=1973|countryname=="Ireland"&year>=1973|countryname=="United Kingdom" & year>=1973;
replace eu_year_dummy=1 if year>=1981&countryname=="Greece";
replace eu_year_dummy=1 if year>=1986&countryname=="Portugal"|year>=1986&countryname=="Spain";
replace eu_year_dummy=1 if year>=1995&countryname=="Austria"|year>=1995&countryname=="Finland"|year>=1995&countryname=="Sweden";
replace eu_year_dummy=1 if year>=2004&countryname=="Cyprus"|year>=2004&countryname=="Czech Republic"|year>=2004&countryname=="Estonia"
|year>=2004&countryname=="Hungary"|year>=2004&countryname=="Latvia"|year>=2004&countryname=="Lithuania"|year>=2004&countryname=="Malta"
|year>=2004&countryname=="Poland"|year>=2004&countryname=="Slovakia"|year>=2004&countryname=="Slovenia"|year>=2007&countryname=="Bulgaria"
|year>=2007&countryname=="Romania"|year>=2013&countryname=="Croatia";
saveold "dta/disagg_milex_working", replace;

*generate eurozone_dummy*
#delimit;
gen eurozone_year_dummy=0;
replace eurozone_year_dummy=1 if year >= 1999 & [countryname=="Austria"|countryname=="Belgium"|countryname=="Netherlands"|countryname=="Finland"|countryname=="France"|countryname=="Germany"|countryname=="Ireland"|countryname=="Italy"|countryname=="Luxembourg"|countryname=="Portugal"|countryname=="Spain"];
replace eurozone_year_dummy=1 if year>=2001 & countryname=="Greece";
replace eurozone_year_dummy=1 if year>=2007 & countryname=="Slovenia";
replace eurozone_year_dummy=1 if year>=2008 & [countryname=="Cyprus"|countryname=="Malta"];
replace eurozone_year_dummy=1 if year>=2009 & countryname =="Slovakia";
replace eurozone_year_dummy=1 if year>=2011 & countryname == "Estonia";
replace eurozone_year_dummy=1 if year>=2014 & countryname == "Latvia";
replace eurozone_year_dummy=1 if year>=2015 & countryname == "Lithuania";
saveold "dta/disagg_milex_working", replace;

*Generate nato_eu_year_dummy*
#delimit;
gen nato_eu_year_dummy=0;
replace nato_eu_year_dummy=1 if nato_year_dummy==1&eu_year_dummy==1;
saveold "dta/disagg_milex_working", replace;

*merge new python scraped data*
*problem here for now is that there are duplicate ccode years because of the nato & eda data*
#delimit;
sort ccode year;
merge 1:1 ccode year using "dta/nato_eda_compiled_data";
drop _merge;
sort ccode year;
replace nato_year_dummy=nato_year_dummy[_n-1] if nato_year_dummy==.;
replace countryname=countryname[_n-1] if countryname=="" & milburden!=.;

*compare new python data*
#delimit;
tsline milburden Milburden if nato_year_dummy==1 & Milburden!=., by(countryname);
list year countryname milburden Milburden if abs(milburden-Milburden)>0 & Milburden!=.;

*merge old python scraped data* 
#delimit;
merge 1:1 ccode year using "dta\disagg_milex_pythonscrape";
drop _merge;


*replace old data with scraped data*
#delimit;
replace milburden=Milburden if Milburden!=.;
replace equipment=Equipment if Equipment!=.;
replace personnel=Personnel if Personnel!=.;
replace operating=Other if Other!=.;
replace infrastructure=Infrastructure if Infrastructure!=.;


saveold "dta\disagg_milex_v2022", replace;

*Correct not adding up to 100 issue by subtracting from operating*
#delimit;
use "dta/disagg_milex_v2022";
gen totald=operating+equipment+infrastructure+personnel;
gen totald_diff=100-totald;
gen operating_corr=operating+totald_diff;
gen totald_corr=operating_corr+equipment+infrastructure+personnel;
rename operating operating_old;
rename operating_corr operating;
rename totald totald_old;
gen totald=operating+equipment+infrastructure+personnel;
sum totald;

saveold "dta/disagg_milex_v2022", replace;

*Generate eda disaggregated data with new scrapes (personnel, infrastructure, o&m no longer available)*
#delimit;
use "dta/disagg_milex_v2022", clear;
gen eda_equipment = eda_equipment_euros/eda_milex*100;
gen edacollabprocurement_milex= eda_collaborativeprocurement/eda_milex*100;
gen edacollabprocurementeu_milex= eda_collaborativeprocurement_eu/eda_milex*100;
gen edacollabrt_milex=eda_collaborative_rt/eda_milex*100;
gen edacollabrteu_milex=eda_collaborative_rt_eu/eda_milex*100;
saveold "dta/disagg_milex_v2022", replace;

*Update EDA data*
#delimit;
use "dta\eda_2019", clear;
drop if year==2017;
append using "dta\eda_2020";
gen eda_personnel = eda_personnel_euros/eda_milex*100;
gen eda_infrastructure = eda_infrastructure_euros/eda_milex*100;
gen eda_equipment = eda_equipment_euros/eda_milex*100;
gen eda_operating_euros = eda_om + eda_om_deployed;
gen eda_operating = eda_operating_euros/eda_milex*100;
gen edacollabprocurement_milex= eda_collaborativeprocurement/eda_milex*100;
gen edacollabprocurementeu_milex= eda_collaborativeprocurement_eu/eda_milex*100;
gen edacollabrt_milex=eda_collaborative_rt/eda_milex*100;
gen edacollabrteu_milex=eda_collaborative_rt_eu/eda_milex*100;
saveold "dta\eda_2020_shares", replace;

*Merge new and old EDA data, convert shares to pecentages* 
#delimit;
use "dta\eda_2020_shares", clear;
merge 1:1 ccode year using "dta/disagg_milex_v2022";
drop _merge;
replace eda_milburden = eda_milburden*100;
replace eda_milshare_budget = eda_milshare_budget*100;
replace personnel = eda_personnel if personnel==.;
replace infrastructure = eda_infrastructure if infrastructure==.;
replace equipment = eda_equipment if equipment==.;
replace operating = eda_operating if operating==.;
replace milburden = eda_milburden if milburden==.;
saveold "dta/disagg_milex_v2022", replace;

*Label EDA Variables*
#delimit;
lab var eda_milburden "EDA Defense Spending (%GDP)";
lab var eda_milshare_budget "EDA Defense Spending (%Budget)";
lab var eda_personnel "EDA Personnel Spending (%Milex)";
lab var eda_infrastructure "EDA Infrastructure Spending (%Milex)";
lab var eda_equipment "EDA Equipment Spending (%Milex)";
lab var eda_operating "EDA O&M Spending (%Milex)";
saveold "dta/disagg_milex_v2022", replace;


*Merge Bove Conscription data*
#delimit;
use "dta/bove_conscription_small", clear;
collapse (mean) lasttime Cohort_conscription adopt adopt_year concomitant, by(year ccode);
merge 1:1 ccode year using "dta/disagg_milex_v2022";
drop _merge;
gen years_since_conscription = year-lasttime;
saveold "dta/disagg_milex_v2022", replace;




*Get WB GDP data 2010 USD*
#delimit;
wbopendata, language(en - English) country() topics() indicator(NY.GDP.MKTP.KD) clear long;
do "do/name_to_cow_easy.do";
sort ccode year;
rename countryname wb_countryname;
drop if ccode==.;
saveold "dta/wb_gdp", replace;
gen ln_gdp=ln(ny_gdp_mktp_kd);
merge 1:1 ccode year using "dta\disagg_milex_v2022";
drop _merge;
drop if ccode==.;
drop if nato_or_eu_year_dummy!=1;
egen rank_on_gdp = rank(-ny_gdp_mktp_kd), by(year);
lab var rank_on_gdp "GDP Rank";
egen rank_on_gdp_pos = rank(ny_gdp_mktp_kd), by(year);
lab var rank_on_gdp_pos "GDP Rank";
saveold "dta\disagg_milex_v2022", replace;



*Get WB GDP per capita (constant 2010 US$)*
#delimit;
wbopendata, language(en - English) country() topics() indicator(NY.GDP.PCAP.KD) clear long;
do "do/name_to_cow_easy.do";
sort ccode year;
rename countryname wb_countryname;
drop if ccode==.;
saveold "dta/wb_gdp_cap", replace;
merge 1:1 ccode year using "dta\disagg_milex_v2022";
drop _merge;
drop if ccode==.;
drop if nato_or_eu_year_dummy!=1;
lab var ny_gdp_pcap_kd "GDP per capita (constant 2010 USD)";
egen rank_on_gdp_cap = rank(-ny_gdp_pcap_kd), by(year);
lab var rank_on_gdp_cap "GDP/capita Rank";
saveold "dta\disagg_milex_v2022", replace;

*Get WB population data*
#delimit;
wbopendata, language(en - English) country() topics() indicator(SP.POP.TOTL) clear long;
do "do/name_to_cow_easy.do";
sort ccode year;
rename countryname wb_countryname;
drop if ccode==.;
saveold "dta/wb_pop", replace;
merge 1:1 ccode year using "dta/disagg_milex_v2022";
drop _merge;
drop if ccode==.;
gen ln_pop=ln(sp_pop_totl);
saveold "dta/disagg_milex_v2022", replace;

*Get WB SIPRI Milex Current USD*
#delimit;
wbopendata, language(en - English) country() topics() indicator(MS.MIL.XPND.CD) clear long;
do "do/name_to_cow_easy.do";
sort ccode year;
rename countryname wb_countryname;
drop if ccode==.;
saveold "dta/wb_gdp", replace;
gen ln_ms_mil_xpnd_cd=ln(ms_mil_xpnd_cd);
merge 1:1 ccode year using "dta\disagg_milex_v2022";
drop _merge;
drop if ccode==.;
drop if nato_or_eu_year_dummy!=1;
lab var ms_mil_xpnd_cd "Milex, Current USD (SIPRI)";
lab var ln_ms_mil_xpnd_cd "Milex, Current USD (SIPRI), ln";
saveold "dta\disagg_milex_v2022", replace;

*Get WB CPI (2010) Data*
#delimit;
wbopendata, language(en - English) country() topics() indicator(FP.CPI.TOTL) clear long;
do "do/name_to_cow_easy.do";
sort ccode year;
rename countryname wb_countryname;
drop if ccode==.;
saveold "dta/wb_cpi_2010", replace;
merge 1:1 ccode year using "dta\disagg_milex_v2022";
drop _merge;
drop if ccode==.;
saveold "dta\disagg_milex_v2022", replace;

*see if fp_cpi_totl is doing anything weird*
#delimit;
sum fp_cpi_totl;

*Merge NATO GDP: WB doesn't go far back enough*
#delimit; 
merge 1:1 ccode year using "dta/nato_gdp";
drop _merge;
drop if nato_or_eu_year_dummy!=1;
gen calc_gdp_cap = calc_gdp/sp_pop_totl;
egen rank_on_calc_gdp = rank(-calc_gdp), by(year);
egen rank_on_calc_gdp_cap = rank(-calc_gdp_cap), by(year);
saveold "dta\disagg_milex_v2022", replace;

*Generate Rankings for milex*
#delimit;
egen rank_on_milburden = rank(-milburden), by(year);

egen rank_on_equipment = rank(-equipment), by(year);
egen rank_on_personnel = rank(-personnel), by(year);
egen rank_on_operating = rank(-operating), by(year);
egen rank_on_infrastructure = rank(-infrastructure), by(year); 

egen rank_on_equipment_gdp = rank(-equipment_gdp), by(year);
egen rank_on_personnel_gdp = rank(-personnel_gdp), by(year);
egen rank_on_operating_gdp = rank(-operating_gdp), by(year);
egen rank_on_infrastructure_gdp = rank(-infrastructure_gdp), by(year); 
saveold "dta\disagg_milex_v2022", replace;

*Generate Original/Olson & Zeckhauser allies' rankings*
#delimit;
gen ognato_dummy=0;
replace ognato_dummy=1 if countryname =="Belgium"|countryname=="Canada"|countryname=="Denmark"|countryname=="France"|countryname=="Germany"|countryname=="Greece"|countryname=="Italy"|countryname=="Luxembourg"|countryname=="Netherlands"|countryname=="Norway"|countryname=="Portugal"|countryname=="Turkey"|countryname=="United Kingdom"|countryname=="United States";
egen og_rank_on_gdp = rank(-ny_gdp_mktp_kd) if ognato_dummy==1, by(year);
egen og_rank_on_gdp_cap = rank(-ny_gdp_pcap_kd) if ognato_dummy==1, by(year);
egen og_rank_on_milburden = rank(-milburden) if ognato_dummy==1, by(year);
egen og_rank_on_equipment = rank(-equipment) if ognato_dummy==1, by(year);
egen og_rank_on_personnel = rank(-personnel) if ognato_dummy==1, by(year);
egen og_rank_on_operating = rank(-operating) if ognato_dummy==1, by(year);
egen og_rank_on_infrastructure = rank(-infrastructure) if ognato_dummy==1, by(year); 
saveold "dta\disagg_milex_v2022", replace;

*List Available Country Years*
#delimit;
tabstat year if equipment_gdp!=. & personnel_gdp!=. & operating_gdp!=. & infrastructure_gdp!=., statistics (min max) by(countryname);

*Merge Sandler & George Data*
*Missing countryname for ccodes 230 255 290 310 316 317 339 344 349 350 355 360 366 367 368 640*
#delimit;
use "dta/me_data", clear;
gen ccode= code_a;
drop _merge;
saveold "dta/me_sandlergeorge_formerge", replace;
use "dta/disagg_milex_v2022", clear;
merge 1:1 ccode year using "dta/me_sandlergeorge_formerge";
drop _merge;

*list missing countrynames*
#delimit;
list year me milburden ccode if countryname=="";
list year countryname milburden if me!=. & milburden==.;
list year countryname me if milburden==. & me!=.;
replace countryname = "Spain" if ccode ==230;
replace countryname = "Germany" if ccode==255;
replace countryname = "Poland" if ccode==290;
replace countryname = "Hungary" if ccode==310;
replace countryname = "Czech Republic" if ccode==316;
replace countryname = "Slovakia" if ccode== 317;
replace countryname = "Albania" if ccode==339; 
replace countryname = "Croatia" if ccode==344;
replace countryname = "Slovenia" if ccode==349;
replace countryname= "Greece" if ccode==350;
replace countryname = "Bulgaria" if ccode==355;
replace countryname = "Romania" if ccode==360;
replace countryname = "Estonia" if ccode==366;
replace countryname = "Latvia" if ccode==367;
replace countryname = "Lithuania" if ccode==368;
replace countryname = "Turkey" if ccode==640;

list year me milburden ccode if countryname=="";
list year countryname milburden if me!=. & milburden==.;
list year ccode countryname me if milburden==. & me!=.;



*Convert SIPRI to 2010 USD, tens of thousands*
#delimit;
replace ms_mil_xpnd_cd = ms_mil_xpnd_cd/1000000;
gen ms_mil_xpnd_cd_usd2010 = ms_mil_xpnd_cd*(100/fp_cpi_totl);


*delog me*
#delimit;
gen exp_me = exp(me);
gen log10_me = log10(me);


*merge nato milex*
#delimit;
merge 1:1 ccode year using "dta/nato_milex_usd2010";
drop _merge;
gen ln_milex_usd2010=ln(milex_usd2010);
gen log_milex_usd2010=log(milex_usd2010);
lab var milex_usd2010 "Milex, 2010 USD (NATO)";
lab var ln_milex_usd2010 "Milex, 2010 USD (NATO), ln";
lab var log_milex_usd2010 "Milex, 2010 USD (NATO), log";

*merge COW NMC v6.0*
#delimit;
merge 1:1 ccode year using "dta/cow_nmc_v6";
drop _merge;
saveold "dta/disagg_milex_v2022", replace;

*generate 2014 versions of 2010 variables*
#delimit;
gen ms_mil_xpnd_usd2014 = ms_mil_xpnd_cd_usd2010*1.09;
gen ln_ms_mil_xpnd_usd2014 = ln(ms_mil_xpnd_usd2014);
gen log_ms_mil_xpnd_usd2014 = log(ms_mil_xpnd_usd2014);

gen milex_usd2014 = milex_usd2010*1.09;
gen ln_milex_usd2014 = ln(milex_usd2014);
gen log_milex_usd2014 = log(milex_usd2014);

*Calculate Shares of SIPRI me and log*
#delimit;
gen equipment_usd2014 = (equipment/100)*ms_mil_xpnd_usd2014;
gen personnel_usd2014 = (personnel/100)*ms_mil_xpnd_usd2014;
gen operating_usd2014 = (operating/100)*ms_mil_xpnd_usd2014;
gen infrastructure_usd2014 = (infrastructure/100)*ms_mil_xpnd_usd2014;

gen ln_equipment_usd2014 = ln(equipment_usd2014);
gen ln_personnel_usd2014 = ln(personnel_usd2014);
gen ln_operating_usd2014 = ln(operating_usd2014);
gen ln_infrastructure_usd2014 = ln(infrastructure_usd2014);

*Calculate Shares of G&S me and log*
#delimit;
gen equipment_me = (equipment/100)*exp_me;
gen personnel_me = (personnel/100)*exp_me;
gen operating_me = (operating/100)*exp_me;
gen infrastructure_me = (infrastructure/100)*exp_me;

gen ln_equipment_me = ln(equipment_me);
gen ln_personnel_me = ln(personnel_me);
gen ln_operating_me = ln(operating_me);
gen ln_infrastructure_me = ln(infrastructure_me);

*Compare Data*

sum me ln_milex_usd2014 ln_ms_mil_xpnd_usd2014 if me!=. & ln_milex_usd2014!=. & ln_ms_mil_xpnd_usd2014!=.;

sum exp_me milex_usd2014 ms_mil_xpnd_usd2014 if exp_me!=. & milex_usd2014!=. & ms_mil_xpnd_cd!=.;

saveold "dta/disagg_milex_v2022", replace;


pwcorr me ln_milex_usd2014 ln_ms_mil_xpnd_usd2014 ln_equipment_me ln_personnel_me ln_operating_me ln_infrastructure_me, star(1);

*Generate nato_eu_dummy*
#delimit;
gen nato_eu_dummy=0;
gen nato_dummy=0;
gen eu_dummy=0;
egen nato_dummy_mean=mean(nato_year_dummy), by(ccode);
egen eu_dummy_mean=mean(eu_year_dummy), by(ccode);
replace nato_eu_dummy=1 if nato_dummy_mean>0&eu_dummy_mean>0;
replace nato_dummy=1 if nato_dummy_mean>0;
replace eu_dummy=1 if eu_dummy_mean>0;
saveold "dta/disagg_milex_v2022", replace;

*Generate nato_or_eu_dummy*
#delimit;
gen nato_or_eu_dummy=0;
replace nato_or_eu_dummy=1 if nato_dummy_mean>0|eu_dummy_mean>0;

drop nato_dummy_mean;
drop eu_dummy_mean;
saveold "dta/disagg_milex_v2022", replace;

*generate non-NATO EU dummy*
#delimit;
gen non_nato_eu_dummy=0;
replace non_nato_eu_dummy=1 if nato_dummy==0 & eu_dummy==1;
saveold "dta/disagg_milex_v2022", replace;

*generate non-EU NATO dummy*
#delimit;
gen non_eu_nato_dummy=0;
replace non_eu_nato_dummy=1 if nato_dummy==1 & eu_dummy==0;
saveold "dta/disagg_milex_v2022", replace;

*drop extraneous data*
#delimit; 
drop if milburden==.;
drop if year>=2100;
drop if year<1945;
saveold "dta/disagg_milex_v2022", replace;

***********************
*Table 1:Summary Stats*
***********************
#delimit;
sum milburden equipment personnel infrastructure operating, format;

***********************************
*Table 2: Summary Stats by Country*
***********************************
#delimit;
tabstat milburden eda_milburden equipment eda_equipment personnel eda_personnel infrastructure eda_infrastructure operating eda_operating if milburden!=. & eda_milburden!=. &non_nato_eu_dummy!=1, statistics (mean min max) by(countryname);

tabstat milburden eda_milburden equipment eda_equipment personnel eda_personnel infrastructure eda_infrastructure operating eda_operating if nato_or_eu_year_dummy==1, statistics (mean min max) by(countryname);

*Table TBD: Summary Stats by Year*
#delimit;
tabstat milburden  equipment  personnel  infrastructure  operating if nato_or_eu_year_dummy==1, statistics (mean min max) by(year);

tabstat milburden eda_milburden equipment eda_equipment personnel eda_personnel infrastructure eda_infrastructure operating eda_operating if nato_or_eu_year_dummy==1, statistics (mean min max) by(countryname);

***************************************
*Table 3: List available country years*
***************************************
#delimit;
tabstat year if milburden!=. & operating!=. & equipment!=. & personnel!=. & infrastructure!=., statistics(min max) by(countryname);
tabstat year if equipment!=. , statistics(min max) by(countryname);

********************************
*Table 4: Pairwise Correlations*
********************************
#delimit;
pwcorr milburden equipment personnel operating infrastructure, star(1);

**************
*REPLICATIONS*
**************
********************
*OLSON & ZECKHAUSER*
********************
#delimit;
use "dta\disagg_milex_v2022", clear;
tsset ccode year;

*merge Olson data from paper*
#delimit;
merge 1:1 ccode year using "dta/olson";
drop _merge;
sort ccode year;
bysort ccode: carryforward olson_gnp, gen(olson_gnp_1964);
bysort ccode: carryforward olson_rank_gnp, gen(olson_rank_gnp_1964);
bysort ccode: carryforward olson_milburden, gen(olson_milburden_1964);
bysort ccode: carryforward olson_milburden_rank, gen(olson_milburden_rank_1964);
bysort ccode: carryforward olson_gnp_cap, gen(olson_gnp_cap_1964);
bysort ccode: carryforward olson_rank_gnp_cap, gen(olson_rank_gnp_cap_1964);

*generate Olson states only ranks*
#delimit;
egen restricted_rank_on_milburden = rank(-milburden) if olson_gnp_1964!=., by(year);
egen restricted_rank_on_gdp = rank(-ny_gdp_mktp_kd) if olson_gnp_1964!=., by(year);
egen restricted_rank_on_gdp_cap = rank(-ny_gdp_pcap_kd) if olson_gnp_1964!=., by(year);

*"TABLE 2 - NATO STATISTICS: AN EMPIRICAL TEST"*
#delimit;
gen gdp_billions= ny_gdp_mktp_kd/1000000000;

*Replicate table exactly as is in paper*
#delimit;
gsort olson_rank_gnp;
tabstat olson_gnp olson_rank_gnp olson_milburden olson_milburden_rank olson_gnp_cap olson_rank_gnp_cap if year==1964 & olson_gnp!=., by(countryname);

*Compare to currently available data*
#delimit;
tabstat olson_gnp calc_gdp olson_rank_gnp rank_on_calc_gdp olson_milburden milburden olson_milburden_rank rank_on_milburden olson_gnp_cap calc_gdp_cap olson_rank_gnp_cap rank_on_calc_gdp_cap if year==1964 & calc_gdp!=. & olson_gnp!=., by(countryname);

*Compare to 2020 data*
#delimit;
tabstat olson_gnp_1964 ny_gdp_mktp_kd olson_rank_gnp_1964 restricted_rank_on_gdp olson_milburden_1964 milburden olson_milburden_rank_1964 restricted_rank_on_milburden olson_gnp_cap_1964 ny_gdp_pcap_kd olson_rank_gnp_cap_1964 restricted_rank_on_gdp_cap if year==2020 &olson_gnp_1964!=., by(countryname);

*Replicate Table for All Data Available*
#delimit;
tabstat ny_gdp_mktp_kd rank_on_gdp milburden rank_on_milburden olson_milburden_rank equipment rank_on_equipment personnel rank_on_personnel operating rank_on_operating infrastructure rank_on_infrastructure, by(countryname);

*Same as above with only ranks - shows how close most are to Olson on milburden*
#delimit;
tabstat og_rank_on_gdp og_rank_on_gdp_cap og_rank_on_milburden olson_milburden_rank og_rank_on_equipment og_rank_on_personnel og_rank_on_operating og_rank_on_infrastructure if ognato_dummy==1, by(countryname);

*****************************
*Spearman for multiple years*
*****************************

*spearman2 GDP Shares & GDP*
#delimit;
spearman2 milburden ny_gdp_mktp_kd if year<=1966;
spearman2 milburden ny_gdp_mktp_kd;
spearman2 equipment ny_gdp_mktp_kd;
spearman2 personnel ny_gdp_mktp_kd;
spearman2 operating ny_gdp_mktp_kd;
spearman2 infrastructure ny_gdp_mktp_kd;

*spearman2 milex shares & GDP*
#delimit;
spearman2 equipment_gdp ny_gdp_mktp_kd;
spearman2 personnel_gdp ny_gdp_mktp_kd;
spearman2 operating_gdp ny_gdp_mktp_kd;
spearman2 infrastructure_gdp ny_gdp_mktp_kd;

*spearman2 GDP Shares & GDP/Capita*
#delimit;
spearman2 milburden ny_gdp_pcap_kd if year<=1966;
spearman2 milburden ny_gdp_pcap_kd;
spearman2 equipment ny_gdp_pcap_kd;
spearman2 personnel ny_gdp_pcap_kd;
spearman2 operating ny_gdp_pcap_kd;
spearman2 infrastructure ny_gdp_pcap_kd;

*spearman2 milex shares & GDP/Capita*
#delimit;
spearman2 equipment_gdp ny_gdp_pcap_kd;
spearman2 personnel_gdp ny_gdp_pcap_kd;
spearman2 operating_gdp ny_gdp_pcap_kd;
spearman2 infrastructure_gdp ny_gdp_pcap_kd;

*****************************
*Spearman for 1964 & 2020   *
*****************************
*spearman2 GDP Shares & GDP: this really shows utility of disaggregating*
#delimit;
spearman2 milburden ny_gdp_mktp_kd if year==1964;
spearman2 milburden ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;
spearman2 equipment ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;
spearman2 personnel ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;
spearman2 operating ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;
spearman2 infrastructure ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;

*spearman2 milex shares & GDP: this shows it to a lesser extent*
#delimit;
spearman2 milburden ny_gdp_mktp_kd if year==1964;
spearman2 equipment_gdp ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;
spearman2 personnel_gdp ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;
spearman2 operating_gdp ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;
spearman2 infrastructure_gdp ny_gdp_mktp_kd if year==2020 & olson_gnp_1964!=.;

*Correlation Coefficients over time*
#delimit;
rangestat (corr) milburden  ln_gdp, int(year 0 0);
rename corr_nobs milburden_corr_nobs;
rename corr_x milburden_ln_gdp_corr_x;

rangestat (corr) personnel_gdp ln_gdp, int (year 0 0);
rename corr_nobs personnel_gdp_nobs;
rename corr_x personnel_gdp_corr_x;

rangestat (corr) equipment_gdp ln_gdp, int (year 0 0);
rename corr_nobs equipment_gdp_nobs;
rename corr_x equipment_gdp_corr_x;

rangestat (corr) infrastructure_gdp ln_gdp, int (year 0 0);
rename corr_nobs infrastructure_gdp_nobs;
rename corr_x infrastructure_gdp_corr_x;

rangestat (corr) operating_gdp ln_gdp, int (year 0 0);
rename corr_nobs operating_gdp_nobs;
rename corr_x operating_gdp_corr_x;

rangestat (corr) personnel ln_gdp, int (year 0 0);
rename corr_nobs personnel_nobs;
rename corr_x personnel_corr_x;

rangestat (corr) equipment ln_gdp, int (year 0 0);
rename corr_nobs equipment_nobs;
rename corr_x equipment_corr_x;

rangestat (corr) infrastructure ln_gdp, int (year 0 0);
rename corr_nobs infrastructure_nobs;
rename corr_x infrastructure_corr_x;

rangestat (corr) operating ln_gdp, int (year 0 0);
rename corr_nobs operating_nobs;
rename corr_x operating_corr_x;

rangestat (corr) milburden rank_on_gdp, int (year 0 0);
rename corr_nobs milburden_rank_on_gdp_nobs;
rename corr_x milburden_rank_on_gdp_corr_x;

rangestat (corr) personnel_gdp rank_on_gdp, int (year 0 0);
rename corr_nobs personnel_rank_on_gdp_nobs;
rename corr_x personnel_rank_on_gdp_corr_x;

rangestat (corr) equipment_gdp rank_on_gdp, int (year 0 0);
rename corr_nobs equipment_rank_on_gdp_nobs;
rename corr_x equipment_rank_on_gdp_corr_x;

rangestat (corr) infrastructure_gdp rank_on_gdp, int (year 0 0);
rename corr_nobs infrastructure_rank_on_gdp_nobs;
rename corr_x infra_rank_on_gdp_corr_x;

rangestat (corr) operating_gdp rank_on_gdp, int (year 0 0);
rename corr_nobs operating_rank_on_gdp_nobs;
rename corr_x operating_rank_on_gdp_corr_x;

saveold "dta\disagg_milex_v2022", replace;

*Regression Coefficients over time (ln_gdp)*

#delimit;
use "dta\disagg_milex_v2022", clear;
rangestat (reg) milburden  ln_gdp, int(year 0 0);
rename reg_nobs milburden_reg_nobs;
rename reg_r2 milburden_reg_r2;
rename reg_adj_r2 milburden_reg_adj_r2;
rename b_ln_gdp	milburden_b_ln_gdp;
rename b_cons milburden_b_cons;
rename se_ln_gdp milburden_se_ln_gdp;
rename se_cons milburden_se_cons;

rangestat (reg) personnel_gdp ln_gdp, int (year 0 0);
rename reg_nobs personnel_reg_nobs;
rename reg_r2 personnel_reg_r2;
rename reg_adj_r2 personnel_reg_adj_r2;
rename b_ln_gdp	personnel_b_ln_gdp;
rename b_cons personnel_b_cons;
rename se_ln_gdp personnel_se_ln_gdp;
rename se_cons personnel_se_cons;

rangestat (reg) equipment_gdp ln_gdp, int (year 0 0);
rename reg_nobs equipment_reg_nobs;
rename reg_r2 equipment_reg_r2;
rename reg_adj_r2 equipment_reg_adj_r2;
rename b_ln_gdp	equipment_b_ln_gdp;
rename b_cons equipment_b_cons;
rename se_ln_gdp equipment_se_ln_gdp;
rename se_cons equipment_se_cons;

rangestat (reg) infrastructure_gdp ln_gdp, int (year 0 0);
rename reg_nobs infrastructure_reg_nobs;
rename reg_r2 infrastructure_reg_r2;
rename reg_adj_r2 infrastructure_reg_adj_r2;
rename b_ln_gdp	infrastructure_b_ln_gdp;
rename b_cons infrastructure_b_cons;
rename se_ln_gdp infrastructure_se_ln_gdp;
rename se_cons infrastructure_se_cons;

rangestat (reg) operating_gdp ln_gdp, int (year 0 0);
rename reg_nobs operating_reg_nobs;
rename reg_r2 operating_reg_r2;
rename reg_adj_r2 operating_reg_adj_r2;
rename b_ln_gdp	operating_b_ln_gdp;
rename b_cons operating_b_cons;
rename se_ln_gdp operating_se_ln_gdp;
rename se_cons operating_se_cons;

saveold "dta\disagg_milex_v2022", replace;

*Regression Coefficients over time (rank_on_gdp)*
#delimit;
use "dta\disagg_milex_v2022", clear;
rangestat (reg) milburden  rank_on_gdp, int(year 0 0);
rename reg_nobs milburden_rank_reg_nobs;
rename reg_r2 milburden_rank_reg_r2;
rename reg_adj_r2 milburden_rank_reg_adj_r2;
rename b_rank_on_gdp	milburden_b_rank_on_gdp;
rename b_cons milburden_rank_b_cons;
rename se_rank_on_gdp milburden_rank_se_rank_on_gdp;
rename se_cons milburden_rank_se_cons;

rangestat (reg) personnel_gdp rank_on_gdp, int (year 0 0);
rename reg_nobs personnel_reg_nobs_rank;
rename reg_r2 personnel_reg_r2_rank;
rename reg_adj_r2 personnel_reg_adj_r2_rank;
rename b_rank_on_gdp	personnel_b_rank_on_gdp;
rename b_cons personnel_b_cons_rank;
rename se_rank_on_gdp personnel_se_rank_on_gdp;
rename se_cons personnel_se_cons_rank;

rangestat (reg) equipment_gdp rank_on_gdp, int (year 0 0);
rename reg_nobs equipment_reg_nobs_rank;
rename reg_r2 equipment_reg_r2_rank;
rename reg_adj_r2 equipment_reg_adj_r2_rank;
rename b_rank_on_gdp	equipment_b_rank_on_gdp;
rename b_cons equipment_b_cons_rank;
rename se_rank_on_gdp equipment_se_rank_on_gdp;
rename se_cons equipment_se_cons_rank;

rangestat (reg) infrastructure_gdp rank_on_gdp, int (year 0 0);
rename reg_nobs infrastructure_reg_nobs_rank;
rename reg_r2 infrastructure_reg_r2_rank;
rename reg_adj_r2 infrastructure_reg_adj_r2_rank;
rename b_rank_on_gdp	infrastructure_b_rank_on_gdp;
rename b_cons infrastructure_b_cons_rank;
rename se_rank_on_gdp infrastructure_se_rank_on_gdp;
rename se_cons infrastructure_se_cons_rank;

rangestat (reg) operating_gdp rank_on_gdp, int (year 0 0);
rename reg_nobs operating_reg_nobs_rank;
rename reg_r2 operating_reg_r2_rank;
rename reg_adj_r2 operating_reg_adj_r2_rank;
rename b_rank_on_gdp	operating_b_rank_on_gdp;
rename b_cons operating_b_cons_rank;
rename se_rank_on_gdp operating_se_rank_on_gdp;
rename se_cons operating_se_cons_rank;
saveold "dta\disagg_milex_v2022", replace;


*Consider Coefplot here?*

*******************
*Hartley & Sandler*
*******************
*Generate Variables DEF PRICE INCOME SPILLINS THREAT STRATEGIC ALLDEF FULL*
#delimit;
use "dta/disagg_milex_v2022", clear;
sort ccode year;


gen DEF=(milburden/100)*ny_gdp_mktp_kd;
gen DEF_personnel=(personnel_gdp/100)*ny_gdp_mktp_kd;
gen DEF_equipment=(equipment_gdp/100)*ny_gdp_mktp_kd;
gen DEF_infrastructure=(infrastructure_gdp/100)*ny_gdp_mktp_kd;
gen DEF_operating=(operating_gdp/100)*ny_gdp_mktp_kd;
gen DEF_check= DEF_personnel + DEF_equipment + DEF_infrastructure + DEF_operating;
sum DEF DEF_check if DEF_personnel!=.&DEF_equipment!=.&DEF_infrastructure!=.&DEF_operating!=.;
saveold "dta/disagg_milex_v2022", replace;

egen PRICE=corr (ny_gdp_mktp_kd milburden), by(ccode);
replace PRICE = -PRICE;
egen PRICE_equipment=corr(ny_gdp_mktp_kd equipment_gdp), by(ccode);
replace PRICE_equipment = -PRICE_equipment;
egen PRICE_personnel=corr(ny_gdp_mktp_kd personnel_gdp), by(ccode);
replace PRICE_personnel = -PRICE_personnel;
egen PRICE_infrastructure=corr(ny_gdp_mktp_kd infrastructure_gdp), by(ccode);
replace PRICE_infrastructure = -PRICE_infrastructure;
egen PRICE_operating=corr(ny_gdp_mktp_kd operating_gdp), by(ccode);
replace PRICE_operating = -PRICE_operating;
lab var PRICE "PRICE";
lab var PRICE_equipment "PRICE (equipment)";
lab var PRICE_infrastructure "PRICE (infrastructure)";
lab var PRICE_operating "PRICE (operating)";
lab var PRICE_personnel "PRICE (personnel)";
replace PRICE=PRICE/1000;
saveold "dta/disagg_milex_v2022", replace;

gen INCOME=ny_gdp_mktp_kd;


#delimit;
egen alldef=total(DEF), by(year);

egen ALLDEF_personnel=total(DEF_personnel), by(year);
egen ALLDEF_equipment=total(DEF_equipment), by(year);
egen ALLDEF_infrastructure=total(DEF_infrastructure), by(year);
egen ALLDEF_operating=total(DEF_operating), by(year);

egen  nato_alldef =total(DEF) if nato_year_dummy==1, by(year);
egen eu_alldef=total(DEF) if eu_year_dummy==1, by(year);
egen nato_eu_alldef=total(DEF) if nato_eu_year_dummy==1, by(year);
egen nato_or_eu_alldef=total(DEF) if nato_or_eu_year_dummy==1, by(year);

gen spillins=alldef-DEF;
gen nato_spillins=nato_alldef-DEF;
gen eu_spillins=eu_alldef-DEF;
gen nato_eu_spillins=nato_eu_alldef-DEF;
gen nato_or_eu_spillins=nato_or_eu_alldef-DEF;

gen full=alldef+INCOME;
gen nato_full=nato_alldef+INCOME;
gen eu_full=eu_alldef+INCOME;
gen nato_eu_full=nato_eu_alldef+INCOME;
gen nato_or_eu_full=nato_or_eu_alldef+INCOME;

gen ln_full=ln(full);
gen ln_nato_full=ln(nato_full);
gen ln_eu_full=ln(eu_full);
gen ln_nato_eu_full=ln(nato_eu_full);
gen ln_nato_or_eu_full=ln(nato_or_eu_full);

gen ln_spillins=ln(spillins);
gen ln_nato_spillins=ln(nato_spillins);
gen ln_eu_spillins=ln(eu_spillins);
gen ln_nato_eu_spillins=ln(nato_eu_spillins);
gen ln_nato_or_eu_spillins=ln(nato_or_eu_spillins);

rename spillins SPILLINS;
saveold "dta/disagg_milex_v2022", replace;


*merge key spatial spillins variables*
#delimit;
use "dta/disagg_milex_v2022", clear;
merge 1:1 ccode year using "C:\Users\jordan.becker\My Drive\1_Research\dta\2019_spillins_formerge";
drop _merge;
saveold "dta/disagg_milex_v2022", replace;


*Generate Spatial Threat*
#delimit;
gen russia_spatial=spatial_spillins_365;
gen russia_intent=.;
replace russia_intent=1.5 if year<=1989;
replace russia_intent=1 if year>1989&year<=2008;
replace russia_intent=1.25 if year>2008&year<=2013;
replace russia_intent=1.5 if year>=2014;
gen threat=russia_spatial*russia_intent;
replace threat=. if threat==0;
gen ln_threat=ln(threat);

gen THREAT=russia_spatial;
saveold "dta/disagg_milex_v2022", replace;

*Generate Strategic Excludability*
#delimit;
gen sandler_strategic=1;
replace sandler_strategic=0 if year>=1953&year<=1966;
replace sandler_strategic=0 if year>=2002&year<=2012;
rename sandler_strategic STRATEGIC;
saveold "dta/disagg_milex_v2022", replace;

*Get DEF variables into millions*
#delimit;
use "dta/disagg_milex_v2022", clear;
replace DEF=DEF/1000000;
replace DEF_personnel=DEF_personnel/1000000;
replace DEF_equipment=DEF_equipment/1000000;
replace DEF_infrastructure=DEF_infrastructure/1000000;
replace DEF_operating=DEF_operating/1000000;
saveold "dta/disagg_milex_v2022", replace;

*Convert INCOME, SPILLINS into millions*
#delimit;
use "dta/disagg_milex_v2022", clear;
replace INCOME = INCOME/1000000;
replace SPILLINS = SPILLINS/1000000;
saveold "dta/disagg_milex_v2022", replace;







*Generate log values*
#delimit;
gen ln_INCOME=ln(INCOME);
gen ln_THREAT=ln(THREAT);
gen ln_SPILLINS=ln(SPILLINS);

gen ln_DEF=ln(DEF);
gen ln_DEF_personnel=ln(DEF_personnel);
gen ln_DEF_equipment=ln(DEF_equipment);
gen ln_DEF_operating=ln(DEF_operating);
gen ln_DEF_infrastructure=ln(DEF_infrastructure);

gen ln_PRICE=ln(PRICE);
gen ln_PRICE_personnel=ln(PRICE_personnel);
gen ln_PRICE_equipment=ln(PRICE_equipment);
gen ln_PRICE_operating=ln(PRICE_operating);
gen ln_PRICE_infrastructure=ln(PRICE_infrastructure);
saveold "dta/disagg_milex_v2022", replace;

*********************************************************************
*Pure Public Good: DEF=f(PRICE, INCOME, SPILLINS, THREAT, STRATEGIC)*
*********************************************************************
#delimit;
use "dta/disagg_milex_v2022", clear;
sort ccode year;

*Model 1 Milex*
#delimit;
xi:xtreg DEF PRICE INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Milex/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
*Model 2 Personnel*
#delimit;
xi:xtreg DEF_personnel PRICE_personnel INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Personnel/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 3 Equipment*
#delimit;
xi:xtreg DEF_equipment PRICE_equipment INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Equipment/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 4 Operating*
#delimit;
xi:xtreg DEF_operating PRICE_operating INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (O&M/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 5 Infrastructure*
#delimit;
xi:xtreg DEF_infrastructure PRICE_infrastructure INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Infrastructure/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

tabstat year if e(sample)==1, statistics(min max) by(countryname);

*Model 6 Milex Post-2004*
#delimit;
xi:xtreg DEF PRICE INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=. & year>=2004,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Milex/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 7 Personnel Post-2004*
#delimit;
xi:xtreg DEF_personnel PRICE_personnel INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=. & year>=2004,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Personnel/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 8 Equipment Post-2004*
#delimit;
xi:xtreg DEF_equipment PRICE_equipment INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=. & year>=2004,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Equipment/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 9 Operating Post-2004*
#delimit;
xi:xtreg DEF_operating PRICE_operating INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=. & year>=2004,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (O&M/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 10 Infrastructure Post-2004**
#delimit;
xi:xtreg DEF_infrastructure PRICE_infrastructure INCOME SPILLINS THREAT STRATEGIC if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=. & year>=2004,  r cluster(ccode);
outreg2 using "output/purepublic.xls", ctitle (Infrastructure/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Replicate with Year FE* 
#delimit;
use "dta/disagg_milex_v2022", clear;

*Model 1 Milex*
#delimit;
xi:xtreg DEF PRICE INCOME SPILLINS THREAT STRATEGIC i.year if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic_yearfe.xls", ctitle (Milex/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
*Model 2 Personnel*
#delimit;
xi:xtreg DEF_personnel PRICE_personnel INCOME SPILLINS THREAT STRATEGIC i.year if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic_yearfe.xls", ctitle (Personnel/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 3 Equipment*
#delimit;
xi:xtreg DEF_equipment PRICE_equipment INCOME SPILLINS THREAT STRATEGIC i.year if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic_yearfe.xls", ctitle (Equipment/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 4 Operating*
#delimit;
xi:xtreg DEF_operating PRICE_operating INCOME SPILLINS THREAT STRATEGIC i.year if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic_yearfe.xls", ctitle (O&M/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 5 Infrastructure*
#delimit;
xi:xtreg DEF_infrastructure PRICE_infrastructure INCOME SPILLINS THREAT STRATEGIC i.year if DEF_personnel!=. & DEF_equipment!=. & DEF_infrastructure!=. & DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepublic_yearfe.xls", ctitle (Infrastructure/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Replicate with log values - no good because of negative values*
#delimit;
use "dta/disagg_milex_v2022", clear;

*Model 1 Milex*
#delimit;
xi:xtreg ln_DEF PRICE ln_INCOME ln_SPILLINS ln_THREAT STRATEGIC if ln_DEF_personnel!=. & ln_DEF_equipment!=. & ln_DEF_infrastructure!=. & ln_DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepubliclog.xls", ctitle (Milex/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
*Model 2 Personnel*
#delimit;
xi:xtreg ln_DEF_personnel PRICE_personnel ln_INCOME ln_SPILLINS ln_THREAT STRATEGIC if ln_DEF_personnel!=. & ln_DEF_equipment!=. & ln_DEF_infrastructure!=. & ln_DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepubliclog.xls", ctitle (Personnel/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 3 Equipment*
#delimit;
xi:xtreg ln_DEF_equipment PRICE_equipment ln_INCOME ln_SPILLINS ln_THREAT STRATEGIC if ln_DEF_personnel!=. & ln_DEF_equipment!=. & ln_DEF_infrastructure!=. & ln_DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepubliclog.xls", ctitle (Equipment/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 4 Operating*
#delimit;
xi:xtreg ln_DEF_operating PRICE_operating ln_INCOME ln_SPILLINS ln_THREAT STRATEGIC if ln_DEF_personnel!=. & ln_DEF_equipment!=. & ln_DEF_infrastructure!=. & ln_DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepubliclog.xls", ctitle (O&M/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 5 Infrastructure*
#delimit;
xi:xtreg ln_DEF_infrastructure PRICE_infrastructure ln_INCOME ln_SPILLINS ln_THREAT STRATEGIC if ln_DEF_personnel!=. & ln_DEF_equipment!=. & ln_DEF_infrastructure!=. & ln_DEF_operating!=.,  r cluster(ccode);
outreg2 using "output/purepubliclog.xls", ctitle (Infrastructure/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;


************************************************************************
*Joint Product 1: ALLDEF = f(PRICE, FULL, SPILLINS, THREAT, STRATEGIC)**
************************************************************************
#delimit;
use "dta/disagg_milex_v2022", clear;

*Model 1 Milex*
#delimit;
use "dta/disagg_milex_v2022", clear;
gen ALLDEF=alldef;
gen FULL=full;

quietly xi:xtreg ALLDEF_operating PRICE_operating FULL SPILLINS THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);

xi:xtreg ALLDEF PRICE FULL SPILLINS THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct1.xls", ctitle (Milex/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;

*Model 2 Personnel*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL SPILLINS THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF_personnel PRICE_personnel FULL SPILLINS THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct1.xls", ctitle (Personnel/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 3 Equipment*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL SPILLINS THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF_equipment PRICE_equipment FULL SPILLINS THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct1.xls", ctitle (Equipment/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 4 Operating*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL SPILLINS THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF_operating PRICE_operating FULL SPILLINS THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct1.xls", ctitle (O&M/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
*Model 5 Infrastructure*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL SPILLINS THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF_infrastructure PRICE_infrastructure FULL SPILLINS THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct1.xls", ctitle (Infrastructure/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;



*************************************************************
*Joint Product 2: ALLDEF = f(PRICE, FULL, THREAT, STRATEGIC)*
*************************************************************
#delimit;
use "dta/disagg_milex_v2022", clear;

gen ALLDEF=alldef;
gen FULL=full;





*Model 1 Milex*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL  THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF PRICE FULL  THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct2.xls", ctitle (Milex/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;

*Model 2 Personnel*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL  THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF_personnel PRICE_personnel FULL  THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct2.xls", ctitle (Personnel/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 3 Equipment*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL  THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF_equipment PRICE_equipment FULL  THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct2.xls", ctitle (Equipment/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 4 Operating*
#delimit;
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL  THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
xi:xtreg ALLDEF_operating PRICE_operating FULL  THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct2.xls", ctitle (O&M/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 5 Infrastructure*
quietly xi:xtreg ALLDEF_operating PRICE_operating FULL  THREAT STRATEGIC if ALLDEF_personnel!=. & ALLDEF_equipment!=. & ALLDEF_infrastructure!=. & ALLDEF_operating!=.,  r cluster(ccode);
#delimit;
xi:xtreg ALLDEF_infrastructure PRICE_infrastructure FULL  THREAT STRATEGIC if e(sample)==1,  r cluster(ccode);
outreg2 using "output/jointproduct2.xls", ctitle (Infrastructure/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;




******************
*Sandler & George*
******************



*Run Sandler & George Code*

***Tables 1 and 2
#delimit;
tsset ccode year;
drop if inlist(ccode,339,344)& year<2009;
drop if inlist(ccode,317,349,355,360,366,367,368)& year<2004;
drop if inlist(ccode,290,310,316)& year<1999;
drop if ccode==230&year<1982;
drop if ccode==395;
xi i.ccode;
saveold "dta/disagg_milex_v2022", replace;


eststo clear;

*Pairwise Correlations of Dependent Variables*
#delimit;
pwcorr me  ln_ms_mil_xpnd_usd2014 ln_milex_usd2014 ln_equipment_me ln_personnel_me ln_operating_me ln_infrastructure_me, star(1);

***************************************************************************************
*Replicate Table 1 (pre-1974) - Just G&S Milex vs. SIPRI Milex - these results are odd*
***************************************************************************************
#delimit
use "dta/disagg_milex_v2022", clear;
*Model 1: Spatial lag of ME (alliance membership)*
#delimit;
eststo:xtivreg2 me (me_sl= gdp_sl pop_sl)gdp pop if year>=1960&year<=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
ereturn list;
outreg2 using "output/georgesandlerTable1pre1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a))   ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_sl= gdp_sl pop_sl)gdp pop if year>=1960&year<=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a))ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*Model 2: Spatial lag of ME (contiguity + US)*
#delimit;
eststo:xtivreg2 me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1960&year<=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1960&year<=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*Model 3: Spatial lag of ME (inverse distance)*
#delimit;
eststo:xtivreg2 me (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1960&year<=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1960&year<=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*look at time series to understand sipri/G&S differences*
#delimit;
tsline me ln_ms_mil_xpnd_usd2014 fp_cpi_totl if e(sample)==1, by(countryname);
tsline fp_cpi_totl if e(sample)==1, by(countryname);

* it looks like the issue is mainly with Turkey*
#delimit;
tsline me ln_ms_mil_xpnd_usd2014 if countryname=="Turkey";
tsline ln_ms_mil_xpnd_usd2014 ms_mil_xpnd_cd ms_mil_xpnd_usd2014 if countryname=="Turkey";
list year ln_ms_mil_xpnd_usd2014 ms_mil_xpnd_cd ms_mil_xpnd_usd2014 if countryname=="Turkey";

sum me ln_ms_mil_xpnd_usd2014 if countryname!="Turkey" & me!=.;

*Run without Turkey (model 2 sipri data is still insignificant!)*
#delimit
use "dta/disagg_milex_v2022", clear;
*Model 1: Spatial lag of ME (alliance membership)*
#delimit;
eststo:xtivreg2 me (me_sl= gdp_sl pop_sl)gdp pop if year>=1960&year<=1974 & countryname!="Turkey", fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974_noturkey.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_sl= gdp_sl pop_sl)gdp pop if year>=1960&year<=1974 & countryname!="Turkey", fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974_noturkey.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*Model 2: Spatial lag of ME (contiguity + US)*
#delimit;
eststo:xtivreg2 me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1960&year<=1974 & countryname!="Turkey", fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974_noturkey.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1960&year<=1974 & countryname!="Turkey", fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974_noturkey.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*Model 3: Spatial lag of ME (inverse distance)*
eststo:xtivreg2 me (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1960&year<=1974 & countryname!="Turkey", fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974_noturkey.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1960&year<=1974 & countryname!="Turkey", fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable1pre1974_noturkey.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*******************************
*Replicate Table 2 (post-1974)*
*******************************

*Model 1: Spatial lag of ME (alliance membership)* 
#delimit;
use "dta/disagg_milex_v2022", clear;
eststo:xtivreg2 me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_milex_usd2014 (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (NATO ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*Model 2: Spatial lag of ME (contiguity + US)*
#delimit;
use "dta/disagg_milex_v2022", clear;
eststo:xtivreg2 me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*Model 3: Spatial lag of ME (inverse distance)*
#delimit;
use "dta/disagg_milex_v2022", clear;
eststo:xtivreg2 me (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_ms_mil_xpnd_usd2014 (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (SIPRI ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= gdp_sldist pop_sldist)gdp pop  if year>=1974, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

esttab using output/table_1_2.csv,compress starlevels(* 0.10 ** 0.05 *** 0.01) replace;

*Replicate Just Models 1, 6 (O&M), 8 & 13 (Infrastructure)*
*Model 1: Spatial lag of ME (alliance membership)* 
#delimit;
use "dta/disagg_milex_v2022", clear;
xtivreg2 me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) replace;

xtivreg2 me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1 & me!=. & ln_operating_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_operating_me (me_sl= gdp_sl pop_sl)gdp pop  if year>=1974 & nato_year_dummy==1 & me!=. & ln_operating_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

*Model 2: Spatial lag of ME (contiguity + US)*
#delimit;
use "dta/disagg_milex_v2022", clear;
xtivreg2 me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974 & me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_infrastructure_me (me_uscont= gdp_uscont pop_uscont)gdp pop  if year>=1974, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlerTable2post1974small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec() cdec(2) pdec(2) tdec(2) append;

***Tables 3-10
#delimit;
use "dta/disagg_milex_v2022", clear;
drop if year<=1967;
xi i.ccode;
gen MAD=0;
replace MAD=1 if year>=1968 & year<1975;
gen FLEX=0;
replace FLEX=1 if year>=1975 & year<1991;
gen mad_sl=MAD*me_sl;
gen flex_sl=FLEX*me_sl;
gen mad_sldist=MAD*me_sldist;
gen flex_sldist=FLEX*me_sldist;
gen mad_slcont=MAD*me_slcont;
gen flex_slcont=FLEX*me_slcont;
gen mad_uscont=MAD*me_uscont;
gen flex_uscont=FLEX*me_uscont;
gen mad_ruscont=MAD*me_ruscont;
gen flex_ruscont=FLEX*me_ruscont;
gen rus_cont=0;
replace rus_cont=1 if inlist(ccode,2,255,290,310,355,360,366,367,368,385,390);
drop if ccode==395;

eststo clear;
xi i.ccode; 
eststo clear; 
*****************************************************************************
*Table 3: NATO military expenditure, 1968–2015 (alliance membership weights)*
*****************************************************************************
#delimit;
eststo:xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

*Replicate just models 6, 8 (personnel), 10 (infrastructure), 11 & 14 (O&M)*
#delimit;
xtivreg2 me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;

xtivreg2 me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if me!=. & ln_personnel_me!=. & ln_infrastructure_me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_personnel_me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if me!=. & ln_personnel_me!=. & ln_infrastructure_me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_infrastructure_me (me_sl mad_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if me!=. & ln_personnel_me!=. & ln_infrastructure_me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop, fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if me!=. & ln_personnel_me!=. & ln_infrastructure_me!=. & ln_operating_me!=., fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_operating_me (me_sl flex_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if me!=. & ln_personnel_me!=. & ln_infrastructure_me!=. & ln_operating_me!=., fe gmm2s  bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable3small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

***********************************************
*Table 4A: NATO military expenditure, 1991–2015*
***********************************************
#delimit;
eststo:xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;


eststo:ivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:ivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me if year>1990,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;


***********************************************
*Table 4B: NATO military expenditure, 1999–2015*
***********************************************
#delimit;
eststo:xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:ivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_cont  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:ivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;




esttab using output/table_3_4.csv,compress starlevels(* 0.10 ** 0.05 *** 0.01) replace;


*Just Panels 1&4 (O&M) from 4A and 4B, 11 & 15 (Infrastructure) from 4B*
#delimit;
xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;

xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990 & me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;

xtivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990 & me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999 & me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

ivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999 & me !=. & ln_infrastructure_me!=.,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;

ivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999 & me !=. & ln_infrastructure_me!=.,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable4small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append; 

******************************************************
*Table 5: Replication of Table 4 with shares of milex*
******************************************************

*Just Panels 1&4 (O&M) from 4A and 4B, 11 & 15 (Infrastructure) from 4B*
#delimit;
xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;

xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990 & me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;

xtivreg2 operating (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>1990 & me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999 & me!=. & ln_operating_me!=., fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 operating (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop if year>=1999, fe gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

ivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999 & me !=. & ln_infrastructure_me!=.,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;

ivreg2 infrastructure (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999 & me !=. & ln_infrastructure_me!=.,  gmm2s bw(1) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append; 


**************************************************************************
*Table 6: NATO military expenditure, 1968–2015 (US + contiguity weights)*
**************************************************************************
#delimit;
eststo clear; 
eststo:xtivreg2 me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

*Just models 6, 10 (infrastructure), 11, 12 (equipment), 14(O&M), 15(infrastructure)*
#delimit;
xtivreg2 me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;

xtivreg2 me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop if me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_infrastructure_me (me_uscont mad_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop if me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop if me!=. & ln_equipment_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_equipment_me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop if me!=. & ln_equipment_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_operating_me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop if me!=. & ln_operating_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

xtivreg2 ln_infrastructure_me (me_uscont flex_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop if me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable6small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

**************************************************************************
*Table 7A: NATO military expenditure, 1990–2015 (US + contiguity weights)*
**************************************************************************
*Replicate this whole table - lots of heterogeneity*
#delimit;
eststo:xtivreg2 me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;


eststo:ivreg2 me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;


**************************************************************************
*Table 7B: NATO military expenditure, 1990–2015 (US + contiguity weights)*
**************************************************************************
*Replicate this whole table - lots of heterogeneity*
#delimit; 
eststo:xtivreg2 me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:ivreg2 me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;


eststo:xtivreg2 me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_uscont= attack_uscont gdp_uscont pop_uscont)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable7b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;



esttab using output/table_6_7.csv.csv,compress starlevels(* 0.10 ** 0.05 *** 0.01) replace;

*Tables 8-9*
***************************************************************************
*Table 8: NATO military expenditure, 1968–2015 (inverse distance weights).*
***************************************************************************
#delimit;
eststo clear; 
eststo:xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_sldist flex_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sldist flex_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist flex_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist flex_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist flex_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

*just replicate models 6 & 9 (O&M)*
#delimit;
xtivreg2 me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
xtivreg2 me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop if me!=. & ln_operating_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_operating_me (me_sldist mad_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop if me!=. & ln_operating_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable8small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

****************************************************************************
*Table 9A: NATO military expenditure, 1991–2015 (inverse distance weights).*
****************************************************************************
#delimit;
eststo:xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:ivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>1990, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9a.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

****************************************************************************
*Table 9B: NATO military expenditure, 1999–2015 (inverse distance weights).*
****************************************************************************
delimit;
eststo:xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:ivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_cont if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure*) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9b.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

esttab using output/table_8_9.csv.csv,compress starlevels(* 0.10 ** 0.05 *** 0.01) replace;

*Replicate 11-15 in both 9A & 9B*
#delimit;
xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>1990 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;


xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999 & me!=. & ln_equipment_me!=. & ln_personnel_me!=. & ln_operating_me!=. & ln_infrastructure_me!=., fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable9small.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;



******************************************************************************************
*Table 5: NATO new allies' military expenditure, 1999–2015 (alliance membership weights).*
******************************************************************************************
#delimit;
preserve;
keep if inlist(ccode,316,310,290,355,366,367,368,360,317,349,339,344);
eststo clear;
xi:xtset ccode year;
eststo:xtivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:ivreg2 me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_equipment_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_personnel_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_operating_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:ivreg2 ln_infrastructure_me (me_sl= attack_sl gdp_sl pop_sl)attacks gdp pop rus_me  if year>=1999, small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable5.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, NO) bdec(5) cdec(2) pdec(2) tdec(2) append;
restore;

****************************************************************************************
*Table 10: NATO new allies' military expenditure, 1999–2015 (inverse distance weights).*
****************************************************************************************
#delimit;
preserve;
keep if inlist(ccode,316,310,290,355,366,367,368,360,317,349,339,344);
eststo:xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) replace;
eststo:xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;

eststo:xtivreg2 me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (G&S ME) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_equipment_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Equipment) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_personnel_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Personnel) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_operating_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (O&M) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;
eststo:xtivreg2 ln_infrastructure_me (me_sldist= attack_sldist gdp_sldist pop_sldist)attacks gdp pop rus_me  if year>=1999, fe small gmm2s bw(3) kernel(bartlett) robust;
outreg2 using "output/georgesandlertable10.xls", addstat(F test: , e(F), Kleibergen-Paap LM Test (Prob > chi-sq):, e(idp), Adjusted R-squared:, e(r2_a)) ctitle (Infrastructure) label addtext(Country FE, YES) bdec(5) cdec(2) pdec(2) tdec(2) append;


list year countryname if e(sample)==1; 

esttab using output/table_5_10.csv,compress starlevels(* 0.10 ** 0.05 *** 0.01) replace;
restore;




*********
*FIGURES*
*********

*Figure 1: Disaggregated Bars for countries with data from 1975 & 2021*
#delimit;
use "dta/disagg_milex_v2022", clear;
tabstat year if equipment_gdp!=. & personnel_gdp!=. & operating_gdp!=. & infrastructure_gdp!=., statistics (min max) by(countryname);
sort ccode year;
gen disagg1975=0;
replace disagg1975=1 if countryname=="Belgium"|countryname=="Canada"|countryname=="Denmark"|countryname=="Germany"|countryname=="Italy"|countryname=="Luxembourg"|countryname=="Netherlands"|countryname=="Norway"|countryname=="Portugal"|countryname=="United Kingdom";


preserve;
graph bar (mean) equipment_gdp (mean) personnel_gdp (mean) operating_gdp (mean) infrastructure_gdp if [year==1975|year==2021] & disagg1975==1, scheme (sj) 
over (year, label(labcolor(red) angle(ninety) labsize(tiny))) 
over(countryname, label(labcolor(black) 
angle(forty_five) labsize(vsmall))) stack yline(2 .4, lcolor(red) lpattern(dash) lwidth(medthick)) 
ytitle("Expenditures/GDP (%), by category (1975 & 2021)", size(small) margin(medium)) legend(rows(1) position(6)  size(vsmall) 
label (1 "equipment") label (2 "personnel") label (3 "O&M")  label (4 "infrastructure")) ysize (10) ylab(0(.5)6.5, labsize(vsmall));
graph save output\Figure1disagg_all.gph, replace;
graph export figures\Figure1disagg_all.tif, replace;
restore;

*Figure 2: Disaggregated Bars for 2021*
#delimit;
use "dta/disagg_milex_v2022", clear;
tabstat year if equipment_gdp!=. & personnel_gdp!=. & operating_gdp!=. & infrastructure_gdp!=., statistics (min max) by(countryname);
sort ccode year;

preserve;
drop if countryname=="Iceland";
graph bar (mean) equipment_gdp (mean) personnel_gdp (mean) operating_gdp (mean) infrastructure_gdp if year==2021, scheme (sj) 
 
over(countryname, label(labcolor(black) 
angle(forty_five) labsize(vsmall))) stack yline(2 .4, lcolor(red) lpattern(dash) lwidth(medthick)) 
ytitle("Expenditures/GDP (%), by category (2021)", size(small) margin(medium)) legend(rows(1) position(6)  size(vsmall) 
label (1 "equipment") label (2 "personnel") label (3 "O&M")  label (4 "infrastructure")) ysize (10) ylab(0(.5)3.5, labsize(vsmall));
graph save output\Figure1disagg_all_2021.gph, replace;
graph export figures\Figure1disagg_all_2021.tif, replace;
restore;

*Figure 3: Disaggregated Bars all Years*
#delimit;
use "dta/disagg_milex_v2022", clear;

tabstat year if equipment_gdp!=. & personnel_gdp!=. & operating_gdp!=. & infrastructure_gdp!=., statistics (min max) by(countryname);
sort ccode year;

preserve;
drop if countryname=="Iceland"|countryname=="United States";
graph bar (mean) equipment_gdp (mean) personnel_gdp (mean) operating_gdp (mean) infrastructure_gdp if year>=1985 & year<=2021, scheme (sj) 
 
over(year, label(labcolor(black) 
angle(forty_five) labsize(vsmall))) stack yline(2 .4, lcolor(red) lpattern(dash) lwidth(medthick)) 
ytitle("Expenditures/GDP (%), by category (2021)", size(small) margin(medium)) legend(rows(1) position(6)  size(vsmall) 
label (1 "equipment") label (2 "personnel") label (3 "O&M")  label (4 "infrastructure")) ysize (10) ylab(0(.5)3.5, labsize(vsmall));
graph save output\Figure3disagg_all_years.gph, replace;
graph export figures\Figure3disagg_all_years.tif, replace;
restore;

*Figure 3 Correlations Over time - milburden & disaggregated milburden*
#delimit;
use "dta/disagg_milex_v2022", clear;
list year countryname milburden_rank_on_gdp_corr_x;
preserve;
keep if year<=2021;
replace milburden_rank_on_gdp_corr_x = -milburden_rank_on_gdp_corr_x;
replace personnel_rank_on_gdp_corr_x = -personnel_rank_on_gdp_corr_x;
replace equipment_rank_on_gdp_corr_x = -equipment_rank_on_gdp_corr_x;
replace infra_rank_on_gdp_corr_x = -infra_rank_on_gdp_corr_x;
replace operating_rank_on_gdp_corr_x = -operating_rank_on_gdp_corr_x;

twoway(tsline milburden_rank_on_gdp_corr_x if year>=1959, lwidth(medium) lcolor(navy))
	  (tsline personnel_rank_on_gdp_corr_x if year>=1959, lwidth(medium) lcolor(maroon))
	  (tsline equipment_rank_on_gdp_corr_x if year>=1959, lwidth(medium) lcolor(green))
	  (tsline infra_rank_on_gdp_corr_x if year>=1959, lwidth(medium) lcolor(orange))
	  (tsline operating_rank_on_gdp_corr_x if year>=1959, lwidth(medium) lcolor(red))
	  , scheme(sj) yline (0)
	  xtitle("") xlab(1959(2)2021, labsize(vsmall) angle(45)) ylab(-.4(.1).8, 
	  labsize(small)) ytitle("Rank Correlation with GDP", size(med) margin(medium))
	  legend(rows(2) size(vsmall) label(1 Milex/GDP)  label (2 Personnel/GDP) label (3 Equipment/GDP) label (4 Infrastructure/GDP) label (5 O&M/GDP));
graph save output\olson_zeckhausertimeseries, replace;
graph export figures\olson_zeckhausertimeseries.tif, replace;
restore;

*Now with Regression Coefficients Instead*

#delimit;
use "dta/disagg_milex_v2022", clear;
list year countryname milburden_b_ln_gdp;
preserve;
keep if year<=2021;
replace milburden_b_rank_on_gdp = -milburden_b_rank_on_gdp;
replace personnel_b_rank_on_gdp = -personnel_b_rank_on_gdp;
replace equipment_b_rank_on_gdp = -equipment_b_rank_on_gdp;
replace infrastructure_b_rank_on_gdp = -infrastructure_b_rank_on_gdp;
replace operating_b_rank_on_gdp = -operating_b_rank_on_gdp;

twoway(tsline milburden_b_rank_on_gdp if year>=1959, lwidth(medium) lcolor(navy))
	  (tsline personnel_b_rank_on_gdp if year>=1959, lwidth(medium) lcolor(maroon))
	  (tsline equipment_b_rank_on_gdp if year>=1959, lwidth(medium) lcolor(green))
	  (tsline infrastructure_b_rank_on_gdp if year>=1959, lwidth(medium) lcolor(orange))
	  (tsline operating_b_rank_on_gdp if year>=1959, lwidth(medium) lcolor(red))
	  , scheme(sj) yline (0)
	  xtitle("") xlab(1959(2)2021, labsize(vsmall) angle(45)) ylab(-.05(.1).45, 
	  labsize(small)) ytitle("Bivariate Regression Coefficient, Milex & GDP Rank", size(small) margin(medium))
	  legend(rows(2) size(vsmall) label(1 Milex/GDP)  label (2 Personnel/GDP) label (3 Equipment/GDP) label (4 Infrastructure/GDP) label (5 O&M/GDP));
graph save output\olson_zeckhausertimeseries_rank, replace;
graph export figures\olson_zeckhausertimeseries_rank.tif, replace;
restore;

***********************
*Figures TBD: Coefplot*
***********************
*Figure 4: Milburden by year*
#delimit;
use "dta\disagg_milex_v2022", clear;
eststo clear;
bys year: eststo: reg milburden rank_on_gdp_pos;
coefplot est*, vert nokey label(Title) drop(_cons) ytitle ("Annual Correlation Coefficient, Milburden & GDP Rank") yline(0) xlabel(.51 "1960" 1 "1991" 1.49 "2022");
graph save output\figure4_milburden_gdp_year.gph, replace;
graph export figures\figure4_milburden_gdp_year.tif, replace;
estimates dir;

*Figure 5: Equipment by year*
#delimit;
eststo clear;
bys year: eststo: reg equipment_gdp rank_on_gdp_pos;
coefplot est*, vert nokey drop(_cons) ytitle("Annual Correlation Coefficient, Equipment & GDP Rank") yline(0) xlabel(.51 "1971" 1 "1996" 1.49 "2022"); 
graph save output\figure5_equipment_gdp_year.gph, replace;
graph export figures\figure5_equipment_gdp_year.tif, replace;
estimates dir;


*Figure 6: O&M by year*
#delimit;
eststo clear;
bys year: eststo: reg operating_gdp rank_on_gdp_pos;
coefplot est*, vert nokey drop(_cons) ytitle("Annual Correlation Coefficient, O&M & GDP Rank") yline(0) xlabel(.51 "1975" 1 "1998" 1.49 "2022"); 
graph save output\figure6_operating_gdp_year.gph, replace;
graph export figures\figure6_operating_gdp_year.tif, replace;
estimates dir;

*Figure 7: Personnel by year*
#delimit;
eststo clear;
bys year: eststo: reg personnel_gdp rank_on_gdp_pos;
coefplot est*, vert nokey drop(_cons) ytitle("Annual Correlation Coefficient, Personnel & GDP Rank") yline(0) xlabel(.51 "1971" 1 "1996" 1.49 "2022");
graph save output\figure7_personnel_gdp_year.gph, replace;
graph export figures\figure7_personnel_gdp_year.tif, replace;
estimates dir;


*Figure 8: Infrastructure by year*
#delimit;
eststo clear;
bys year: eststo: reg infrastructure_gdp rank_on_gdp_pos;
coefplot est*, vert nokey drop(_cons) ytitle("Annual Correlation Coefficient, Infrastructure & GDP Rank") yline(0) xlabel(.51 "1975" 1 "1998" 1.49 "2022"); 
graph save output\figure8_infrastructure_gdp_year.gph, replace;
graph export figures\figure8_infrastructure_gdp_year.tif, replace;
estimates dir;

*Milburden by country*
#delimit;
eststo clear;
bys countryname: eststo: reg milburden rank_on_gdp_pos;
coefplot est*, nokey drop(_cons) ytitle("Coefficients by Country, milburden") xline(0) ylabel(); 
graph save output\milburden_country.gph, replace;
graph export figures\milburden_country.tif, replace;
estimates dir;

*Equipment by country*
#delimit;
eststo clear;
bys countryname: eststo: reg equipment_gdp rank_on_gdp_pos;
coefplot est*, nokey drop(_cons) ytitle("Coefficients by Country, equipment") xline(0) ylabel(); 
graph save output\equipment_gdp_country.gph, replace;
graph export figures\equipment_gdp_country.tif, replace;
estimates dir;

*personnel by country*
#delimit;
eststo clear;
bys countryname: eststo: reg personnel_gdp rank_on_gdp_pos;
coefplot est*, nokey drop(_cons) ytitle("Coefficients by Country, personnel") xline(0) ylabel(); 
graph save output\personnel_gdp_country.gph, replace;
graph export figures\personnel_gdp_country.tif, replace;
estimates dir;

*operating by country*
#delimit;
eststo clear;
bys countryname: eststo: reg operating_gdp rank_on_gdp_pos;
coefplot est*, nokey drop(_cons) ytitle("Coefficients by Country, operating") xline(0) ylabel(); 
graph save output\operating_gdp_country.gph, replace;
graph export figures\operating_gdp_country.tif, replace;
estimates dir;

*infrastructure by country*
#delimit;
eststo clear;
bys countryname: eststo: reg infrastructure_gdp rank_on_gdp_pos;
coefplot est*, nokey drop(_cons) ytitle("Coefficients by Country, infrastructure") xline(0) ylabel(); 
graph save output\infrastructure_gdp_country.gph, replace;
graph export figures\infrastructure_gdp_country.tif, replace;
estimates dir;

*coefplot all years*
#delimit;
sort ccode year;
eststo clear;
eststo: xtreg milburden l.rank_on_gdp_pos year if operating!=. & equipment!=. & personnel!=. & infrastructure!=., fe;
eststo: xtreg equipment l.rank_on_gdp_pos year if operating!=. & equipment!=. & personnel!=. & infrastructure!=., fe;
eststo: xtreg personnel l.rank_on_gdp_pos year if operating!=. & equipment!=. & personnel!=. & infrastructure!=., fe;
eststo: xtreg operating l.rank_on_gdp_pos year if operating!=. & equipment!=. & personnel!=. & infrastructure!=., fe;
eststo: xtreg infrastructure l.rank_on_gdp_pos year if operating!=. & equipment!=. & personnel!=. & infrastructure!=., fe;
coefplot est*, drop(_cons year) xline(0);
estimates dir;

#delimit;
eststo clear;
xtreg milburden equipment personnel operating infrastructure l.rank_on_gdp_pos;
coefplot, drop (_cons year) xline(0);

*supplementary figures: structural break in personnel?*
#delimit;
tsline personnel_gdp if nato_year_dummy==1 & year>=1985, by(countryname);
tsline milburden if nato_year_dummy==1 & year>=1985, by(countryname);
preserve;
collapse (mean) milburden personnel personnel_gdp, by(year);
tsline milburden if year>=1985 & year<=2021;
tsline personnel if year>=1985 & year<=2021;
tsline personnel_gdp if year>=1985 & year<=2021;
